package com.corejava.training.unitest;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CalculatorTestWithBeforeAfter {

	Calculator cal = null;

	@Before
	public void init() {
		cal = new Calculator();
	}

	@Test
	public void testAdd() {
		int result = cal.add(2, 4);
		TestCase.assertEquals(6, result);
	}

	@Test
	public void testSubtract() {
		int result = cal.subtract(3, 2);
		TestCase.assertEquals(1, result);
	}

	@Test
	public void testMultiply() {
		int result = cal.multiply(4, 3);
		TestCase.assertEquals(12, result);

	}

	@Test
	public void testDivide() {
		int result = cal.divide(16, 2);
		TestCase.assertEquals(8, result);
	}

	@After
	public void teardown() {
		cal = null;
	}

}
